home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Virtual User tools / SPEC S&L v.1.0.1 / Scripts / Freehand.vu < prev    next >
Encoding:
Text File  |  1993-12-17  |  12.5 KB  |  334 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:        Freehand.vu
  5. #
  6. #    Contains:    Quick look test script for Freehand version 3.1
  7. #
  8. #    Written by:    Kevin Avoy, Ken Landreth, Michael Leong, Gil Spencer et al
  9. #
  10. #    Copyright:    © 1993 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #     <1.0.7>    12/13/93    KTA        ModifyDocument returns a -1 if Scrapbook test fails.
  19. #     <1.0.6>     9/28/93    KTA        Added returnVal for ModifyDocument hook.
  20. #     <1.0.3>     7/19/93    KTA        Updates for FindWindow() to handle descriptors.
  21. #     <1.0.2>     6/16/93    NAGA        Renaming InitGlobals(ScriptLevel)to InitGlobals(ScriptLevel)
  22. #        <1+>     5/25/93    NAGA        Adding header and porting old files to follow new standards
  23. #
  24. # ****************************************************************************
  25. #
  26.  
  27.  
  28.  
  29. ########################################################################
  30. #                            External libraries 
  31. #=======================================================================
  32. Libraries "Output.Lib", "DoTasks.Lib","Draw.Lib","DA.Lib","UserInterface.Lib", "Font.Lib", "Globals.Lib", "LaunchQuit.Lib", "TCS.Lib";
  33.  
  34.  
  35. #########################################################################
  36. ########               Application Specific Tasks
  37. #########################################################################
  38.  
  39. #########################################################################
  40. #                        InitAppGlobals()
  41. #========================================================================
  42. # Author:        Kevin Avoy
  43. # Description:    Sets up the tool palette for Freehand.  This task
  44. #                must be called first.
  45. # Parameters:    None
  46. # Returns:        Nothing
  47. # Examples:        InitAppGlobals()
  48. #========================================================================
  49. # History:
  50. #
  51. #########################################################################
  52. task InitAppGlobals()
  53. begin
  54.                 
  55.     logstr("setting up {global gApptitle}'s globals");            
  56.     global kClick, kDrag, kDragClick, kMultiDrag, kMultiClickDrag, kMultiClick;
  57.     global kPalDocWind, kPalWind, kPullOffPal, kPopUpPal, kScrollPal;
  58.     global kToolPaletteNum := 1; 
  59.     global kLinePaletteNum := 0;
  60.     global kPatternPaletteNum := 0;
  61.     global kColorPaletteNum := 2;
  62.  
  63.     global gLineWeights := {'Hairline','.5 pt','1 pt','1.5 pt','2 pt','4 pt','6 pt','8 pt','12 pt'};
  64.                         
  65.     global gScreenInset := {0,35,0,0};            # Screen inset
  66.     global gDocumentWindow := [window c:True g:True z:True]!;
  67.     global gPaletteList :=    {
  68.                             {                        #### Start Palette #1 - Tools
  69.                             {'Tools',12},            # List := {Specifier for Palette window ("String" if TITLE, integer if ORD), Header height}.
  70.                             kPalWind,                # Palette type
  71.                             {2,9},                    # Size of Tool matrix {numElemsWide,numElemsTall}
  72.                             {25,18}                    # Offset between tools {h,v}
  73.                             },                        #### End Palette #1
  74.                             {                        #### Start Palette #2 - Colors
  75.                             {'Colors',43},            # List := {Specifier for Palette window ("String" if TITLE, integer if ORD), Header height}.
  76.                             kPalWind,                # Palette type
  77.                             {1,8},                    # Size of Tool matrix {numElemsWide,numElemsTall}
  78.                             {0,12}                    # Offset between tools {h,v}
  79.                             }                        #### End Palette #1
  80.     };
  81.     
  82.     # Need to set up and redefine color palette, default has only none, black and white
  83.     
  84.     ### FreeHand                                                                    {Flag, Pattern, Line, Color}
  85.     ### Palette Elements:=        Tool#, Pal#,     ToolName,     ToolType,    DblClktoEnd        SetAttributes
  86.     global ArrowTool         :=     { 1,     1,        "Arrow",        kClick,         0,                 {0}};
  87.     global CharTool         :=     { 2,     1,        "Char",         kClick,        0,                 {global gTextStr,0,0,0}};
  88.     global RectTool         :=     { 3,     1,        "Rect",            kDrag,         0,                 {2,0,1,0}};
  89.     global RoundRectTool    :=     { 4,      1,        "RoundRect",    kDrag,         0,                 {2,0,1,0}};
  90.  
  91.     global OvalTool         :=     { 5,     1,        "Oval",            kDrag,        0,                 {2,0,1,0}};
  92.     global LineTool         :=     { 6,      1,        "Line",            kDrag,         0,                 {2,0,1,0}};
  93.     global FreeHandTool     :=     { 7,      1,        "FreeHand",        kMultiDrag,    0,                 {0}};
  94.     global PointTool         :=     { 8,      1,        "Point",        kMultiClick,0,                 {2,0,1,0}};
  95.  
  96.     global KnifeTool         :=     { 9,     1,         "Knife",        kClick,        0,                 {0}};
  97.     global BezRound             :=     { 10,     1,        "BezRound",        kMultiClick, 1,             {2,0,1,0}};
  98.     global BezStraight        :=     { 11,     1,        "BezStraight",    kMultiClick, 1,             {2,0,1,0}};
  99.     global BezCorner        :=     { 12,     1,        "BezCorner",    kMultiClick, 1,             {2,0,1,0}};
  100.  
  101.     global NewAngle             :=     { 13,     1,         "NewAngle",        kDrag,        0,                 {0}};
  102.     global MirrorAngle         :=     { 14,     1,         "MirrorAngle",    kDrag,        0,                 {0}};
  103.     global Porportion         :=     { 15,     1,         "Porportion",    kDrag,        0,                 {0}};
  104.     global Perspective         :=     { 16,     1,         "Perspective",    kDrag,        0,                 {0}};
  105.     global DupSelect         :=     { 17,     1,         "DupSelect",    kDrag,        0,                 {2,0,1,0}};
  106.     global ZoomTool             :=     { 18,     1,         "ZoomTool",        kClick,        0,                 {0}};
  107.  
  108.     # Need to add color attribute once color palette is setup and redefined
  109.  
  110.     # global Tool list
  111.     global gToolList:={    ArrowTool, 
  112.                         #CharTool,
  113.                         RectTool,
  114.                         RoundRectTool,
  115.                         
  116.                         OvalTool,
  117.                         LineTool,
  118.                         FreeHandTool,
  119.                         PointTool,
  120.                         
  121.                         KnifeTool,
  122.                         BezRound,
  123.                         BezStraight,
  124.                         BezCorner,
  125.                         
  126.                         NewAngle,
  127.                         MirrorAngle,
  128.                         Porportion,
  129.                         Perspective,
  130.                         
  131.                         DupSelect,
  132.                         ZoomTool                    
  133.     };
  134.  
  135.         ### font characteristic lists
  136.     global gFontSizeList := {'8','9','10','11','12','14','18','24','36','48','72'};
  137.     global gFontStyleList := {};
  138.  
  139.     
  140.         ### Name of the Plain (style) menu item  ####
  141.     global gPlainStyle := "Plain";            # Plain-Style menu item
  142.  
  143.         ### How to get to the next line
  144.     global gNextLineMethod := 1;            
  145.         ### 1 - ReturnKey,  2 - EnterKey, 3 - DownArrow Key, 4 - TabKey, {} - Move/Click, {'Untitled'} - Move relative to the window titled 'Untitled' /Click
  146.     
  147.         ### Does moving to the next line clear all font info
  148.     global gNextLineClearsFontSettings := 0;                        
  149.  
  150. end; # InitAppGlobals
  151.  
  152. #########################################################################
  153. #                        DoDrawFreehand()
  154. #========================================================================
  155. # Author:        KTA
  156. # Description:    Does Freehand draw. 
  157. # Parameters:    None
  158. # Returns:        Nada
  159. # Examples:        DoDrawFreehand();
  160. # Assumptions:    FreeHand
  161. #========================================================================
  162. # History:
  163. #
  164. #########################################################################
  165. task DoDrawFreehand()
  166. begin
  167.     if not match [window t:'Tools']!                # if tools window not available
  168.         SelectMenuItem("Toolbox","Windows","View");    # display it
  169.     if not match [window t:'Colors']!                # if Colors window not available
  170.         SelectMenuItem("Colors","Windows","View");    # display it
  171.     DoDraw(, global gDocumentWindow);
  172.     if match [window t:'Colors']!                    # if Colors window open
  173.         SelectMenuItem("Colors","Windows","View");    # close it
  174. end;
  175.  
  176. #########################################################################
  177. #                        DoTextFreehand()
  178. #========================================================================
  179. # Author:        KTA
  180. # Description:    Does Freehand text. 
  181. # Parameters:    None
  182. # Returns:        Nada
  183. # Examples:        DoTextFreehand();
  184. # Assumptions:    FreeHand
  185. #========================================================================
  186. # History:
  187. #
  188. #########################################################################
  189. task DoTextFreehand()
  190. begin
  191.     if match [window t:'Colors']!                    # if Colors window open
  192.         SelectMenuItem("Colors","Windows","View");    # close it
  193.     if not match [window t:'Tools']!                # if tools window not available
  194.         SelectMenuItem("Toolbox","Windows","View");    # display it
  195.     if match [window t:'Tools']!                    # if tools window now available
  196.     begin
  197.         SetTool(global CharTool);                    # select the char tool
  198.         SelectMenuItem("Toolbox","Windows","View");    # close the tools window
  199.         MoveRelativeToWindow(,,,2);                    # click in doc window to define text box
  200.         if Findwindow('Text')                        # if text window pops open
  201.         begin
  202.             DoText();
  203.             if match [button t:'OK' e:true]!
  204.                 SpecialKey(EnterKey, "EnterKey");    # scraptext set up properly
  205.             else begin 
  206.                 selectbutton('Cancel');                # scraptext not set up properly
  207.                 logstr("!@#$% Problem with DoText!  No text typed in window!");
  208.             end;
  209.         end; # if Findwindow('Text')
  210.         else
  211.             logstr("!@#$% There was a problem opening the text window!
  212.               text not tested!");
  213.     end; # if match [window t:'Tools']!
  214.     else
  215.         logstr("!@#$% There was a problem accessing the tools window!
  216.           text not tested!");
  217. end;
  218.  
  219. #########################################################################
  220. #                            FreeHandModifyDocument()
  221. #========================================================================
  222. # Author:        ML
  223. # Description:    Modify FreeHand Document
  224. # Parameters:    None
  225. # Returns:        Nothing
  226. # Examples:        FreeHandModifyDocument();
  227. # Assumptions:    None 
  228. # Applications:    FreeHand
  229. #========================================================================
  230. # History:
  231. #
  232. #########################################################################
  233. task FreeHandModifyDocument()
  234. begin
  235.     retVal := Scrapbook(global kScrapPICT);
  236.     if not(retVal)
  237.         retVal := -1;        # ScrapBook failed so can't modifyDoc
  238.     else
  239.         retVal := 1;
  240.         
  241.     return(retVal);
  242. end;
  243.  
  244. #########################################################################
  245. #                            FreeHandScrapText()
  246. #========================================================================
  247. # Author:        ML
  248. # Description:    Paste text into FreeHand Document
  249. # Parameters:    None
  250. # Returns:        Nothing
  251. # Examples:        FreeHandScrapText();
  252. # Assumptions:    None 
  253. # Applications:    FreeHand
  254. #========================================================================
  255. # History:
  256. #
  257. #########################################################################
  258. task FreeHandScrapText()
  259. begin
  260.     if match [window t:'InfoBarWin']!                # if InfoBarWin window open
  261.         SelectMenuItem("Info Bar","Windows","View");    # close it
  262.     if match [window t:'Colors']!                    # if Colors window open
  263.         SelectMenuItem("Colors","Windows","View");    # close it
  264.     if match [window t:'Layers']!                    # if Layers window open
  265.         SelectMenuItem("Layers","Windows","View");    # close it
  266.     if match [window t:'Styles']!                    # if Styles window open
  267.         SelectMenuItem("Styles","Windows","View");    # close it
  268.     if not match [window t:'Tools']!                # if tools window not open
  269.         SelectMenuItem("Toolbox","Windows","View");    # display it
  270.     if match [window t:'Tools']!                    # if tools window now available
  271.     begin
  272.         SetTool(global CharTool);                    # select the char tool
  273.         SelectMenuItem("Toolbox","Windows","View");    # close the tools window
  274.         MoveRelativeToWindow(,,,2);                    # click in doc window to define text box
  275.         if Findwindow('Text')                        # if text window pops open
  276.         begin
  277.             Scrapbook(global kScrapText);
  278.             if match [button t:'OK' e:true]!
  279.                 SpecialKey(EnterKey, "EnterKey");    # scraptext set up properly
  280.             else begin 
  281.                 selectbutton('Cancel');                # scraptext not set up properly
  282.                 logstr("!@#$% Scraptext not set up properly!");
  283.             end;
  284.         end; # if Findwindow('Text')
  285.         else
  286.             logstr("!@#$% There was a problem opening the text window!
  287.               Scraptext not tested!");
  288.     end; # if match [window t:'Tools']!
  289.     else
  290.         logstr("!@#$% There was a problem accessing the tools window!
  291.           Scraptext not tested!");
  292. end;
  293.  
  294. ################################################################################
  295. ####################             Main script                    ####################
  296. ################################################################################
  297. script Freehand (ScriptLevel:= -1)
  298. begin
  299.     InitGlobals(ScriptLevel);
  300.     InitDraw();
  301.     InitFonts();
  302.     global gApptitle := "Aldus FreeHand";
  303.     global gAppVersion := '3';                            # version of app you will be running
  304.     global gModifyDocument:= task FreeHandModifyDocument; # define app specific task
  305.     global gCustomScrapText:= task FreeHandScrapText;     # define app specific task    
  306.     SuiteStart('Freehand.vu');                                        # begin a new test suite
  307.     if LaunchTwitch("{gAppTitle}",gAliasDirectory)        # launch or twitch to your app
  308.     begin
  309.         global gFileName := "@!@-{gBuildVers}-FreeHand";
  310.         global gSetLine := Task SetLineMenuItems;        # Requires VU 2.0
  311.         InitAppGlobals();                                # init app specific globals
  312.         (*
  313.         *)
  314.         
  315.         DoSetUpApp(,-1,,1,1,1,1);
  316.         
  317.         DoDrawFreehand();
  318.         
  319.         DoTextFreehand();
  320.         
  321.         DoWindow(,global gDocumentWindow);
  322.         
  323.         DoCloseApp(1,-1);
  324.         
  325.         LogStr("############################# LIMITATIONS: ############################");
  326.         LogStr("NOTE: Only 'Plain' text is tested in DoText because not all fonts 
  327.         have all styles enabled");
  328.  
  329.     end; # if LaunchTwitch("{gAppTitle}",gAliasDirectory)
  330.     SuiteEnd();
  331. end; # script Freehand
  332.  
  333. ### What's Needed
  334. # 1) Figure out way to setup color palette - default has only none, black and white